﻿using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            int a;
            a=int.Parse(Console.ReadLine());
            Console.WriteLine("请输入a");
            //int b = 1;
            int sum = jcSum(a);
            

            //for (int i = 1; i <= a; i++)
            //{

            //    b = b * i;
            //    sum = b + sum;

            //}
            Console.WriteLine("a的阶乘的和是：" + sum);
            static int jc(int n)
            {
                int jc = 1;
                for (int i = 1; i <= n; i++)
                {
                    jc = jc * i;

                }

                return jc;
            }
             static int jc1(int n)
            {
                int jc1 = 0;
                for (int i = 1; i <= n; i++)
                {
                    jc1 = jc1 + jc(i);
                }
                return jc1;
            }
            static int jcSum(int n)
            {
                int sum = 0;
                for (int i = 1; i <= n; i++)
                {
                    //        i = 1 sum += jc(1)  i = 2  sum += jc(2)  i = 3 sum += jc(3)
                    sum += jc1(i);
                }
                return sum;
            }
        }
    }
}
